﻿using System;
using System.Collections.Generic;
using System.Text;
using Abp.AutoMapper;
using FwProject.Core.FactoryInfo;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using FwProject.Core.SettlementInfoModel;
using FwProject.Authorization.Users;
using Abp.Domain.Entities.Auditing;
using Abp.Domain.Entities;
using Abp.Application.Services.Dto;
using AutoMapper;
using FwProject.PrePaymentInfo;
using System.ComponentModel;
using FwProject.Comm.ExcelUtil;

namespace FwProject.Settlement.Dto
{
    [DisplayName(displayName:"分配收据")]
    [AutoMap(typeof(SettlementInfo))]
    public class SettlementInfoDto : EntityDto<Guid>
    {
        /// <summary>
        /// 餐厅
        /// </summary>
        /// <value>The restaurantid.</value>
        [Display(Name = "餐厅编号")]
        public Guid Restaurantid { get; set; }
        [Display(Name = "餐厅")]
        [ExcelDateMember(IsClass =true)]
        public RestaurantInfoModel RestaurantInfoModel { get; set; }

        [Display(Name = "单号")]
        [DisplayName(displayName:"单号")]
        [ExcelDateMember]
        public string CreationNumber { get; set; }
        /// <summary>
        /// 应收金额
        /// </summary>
        /// <value>The totalprice.</value>
        [Display(Name = "应收金额")]
        [DisplayName(displayName:"应收金额")]
        [ExcelDateMember]
        public decimal Totalprice { get; set; } = 0;
        /// <summary>
        /// 制单优惠
        /// </summary>
        /// <value>The discountprice.</value>
        [Display(Name = "制单优惠")]
        [DisplayName(displayName:"制单优惠")]
        [ExcelDateMember]
        public decimal Discountprice { get; set; } = 0;

        /// <summary>
        /// 收款优惠
        /// </summary>
        [Display(Name = "收款优惠")]
        public decimal ReceivedDiscount { get; set; }

        /// <summary>
        /// 实际金额
        /// </summary>
        /// <value>The actualprice.</value>

        [Display(Name = "实际金额")]
        [DisplayName(displayName: "收款金额")]
        [ExcelDateMember]
        public decimal Actualprice { get; set; } = 0;

        /// <summary>
        /// 实际收款金额
        /// </summary>
        public decimal ReceivedPrice { get; set; }

        /// <summary>
        /// 使用预收金
        /// </summary>
        public decimal UsePrePayment { get; set; }

        [Display(Name = "审核状态")]
        public ExamineStatus ExamineStatus { get; set; }

        [Display(Name = "支付确认状态")]
        public RestaurantPayStatus RestaurantPayStatus { get; set; }
        /// <summary>
        /// 收款司机
        /// </summary>
        /// <value>The employee driverid.</value>
        [Display(Name = "司机编号")]
        public long? EmployeeDriverid { get; set; }
        [Display(Name = "收款司机")]
        public UserModel EmployeeDriverDao { get; set; }

        /// <summary>
        /// 配送时间 2018-01-01-2018--01-31 当月
        /// 2018-01-01 当日
        /// </summary>
        public string DeliveryDate { get; set; }
        /// <summary>
        /// 默认定期结算特殊情况按照日结系统默认自动生成数据。
        /// </summary>
        public FwProject.Core.Restaurant.BalanceWayEnum BalanceWayEnum { get; set; } = FwProject.Core.Restaurant.BalanceWayEnum.定期结算;

        /// <summary>
        /// 收据备注
        /// </summary>
        public string RemarksConten { get; set; }

        public long? CreatorUserId { get; set; }
        public DateTime CreationTime { get; set; }

        /// <summary>
        /// 已收金额
        /// </summary>
        [IgnoreMap]
        public decimal AlreadyPrice { get { return ReceivedDiscount + ReceivedPrice + UsePrePayment; } }

        public ToVoidStatus ToVoidStatus { get; set; }
    }

    public class RestaurantInfoModel
    {
        /// <summary>
        /// 工厂
        /// </summary>
        public Guid? FactoryinfoId { get; set; }
        /// <summary>
        /// 餐厅地址
        /// </summary>
        /// <value>The restaurant address.</value>
        public string RestaurantAddress { get; set; }
        // <summary>
        /// 餐厅名称
        /// </summary>
        /// <value>The name of the restaurant.</value>
        public string RestaurantName { get; set; }

    }

    public class UserModel
    {
        public string Mobile { get; set; }
        public string Name { get; set; }
    }
}
